//
//  ZQSubTagCell.m
//  BuDeJie
//
//  Created by 仲琦 on 16/4/6.
//  Copyright © 2016年 仲琦. All rights reserved.
//

#import "ZQSubTagCell.h"
#import "ZQSubTagItem.h"
#import "UIImage+ZQRender.h"
#import <UIImageView+WebCache.h>
@interface ZQSubTagCell ()

@property (weak, nonatomic) IBOutlet UIImageView *imageV;

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;

@property (weak, nonatomic) IBOutlet UILabel *numLabel;

@property (weak, nonatomic) IBOutlet UIButton *SubBtn;


@end
@implementation ZQSubTagCell

- (void)setItem:(ZQSubTagItem *)item
{
    _item = item;
    
    //使用 框架添加url图片  ,设置占位图片
    [_imageV sd_setImageWithURL:[NSURL URLWithString:item.image_list] placeholderImage:[UIImage imageNamed:@"defaultUserIcon"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        
        if (image == nil) return ;
        
        
        self.imageV.image = [image circleImage];
        
    }];
    
    //添加标题
    _titleLabel.text = item.theme_name;
    
    //设置副标题
    NSString *str = [NSString stringWithFormat:@"%@人订阅", item.sub_number];
    
    NSInteger num = str.intValue;
    
    if (num > 10000) {
        CGFloat numf = num / 10000.0;
        str = [NSString stringWithFormat:@"%.1f万人订阅", numf];
        str = [str stringByReplacingOccurrencesOfString:@".0" withString:@""];
    }
    
    _numLabel.text = str;
    

    
}


-(void)setFrame:(CGRect)frame
{
    frame.size.height -= 1;
    
    [super setFrame:frame];
}

//从xib加载时就会调用, 仅调用一次
-(void)awakeFromNib
{
    //这个方法在iOS9之前会使画面帧数不稳定,形成卡顿. 有矩尺
//    //设置圆角
//    self.imageV.layer.cornerRadius = self.imageV.zq_width *0.5;
//    //超出主层边框就会被裁剪掉
//    self.imageV.layer.masksToBounds = YES;
    
    
}

@end
